import 'package:dk_flutter_base/dk_ui.dart';

import 'input_widget.dart';
class MutipleRemarkWidget extends StatefulWidget {
  final String title;
  //占位符
  final String placeholder;
  //最多输入文字
  final int maxLength;
  //文本控制器
  final TextEditingController controller;
  //是否显示底部最多显示字数的文本
  final bool showWaringText;
  //焦点
  final FocusNode focusNode;
  //占位符风格
  final TextStyle placeholderStyle;
  //文字风格
  final TextStyle textStyle;
  //最多少字文字风格
  final TextStyle waringTextStyle;
  //文字背景颜色
  final Color textBgColor;
  //文字背景颜色
  final Color bgColor;
  //是否可编辑
  final bool readOnly;
  //内容区高度
  final double contentHeight;
  //按下return（完成键）键收起键盘
  final bool returnKeyDownKeyBoard;

  MutipleRemarkWidget({
    this.title = "",
    this.placeholder = "",
    this.maxLength = 100,
    @required this.controller,
    this.showWaringText = false,
    this.focusNode,
    this.textStyle,
    this.waringTextStyle,
    this.placeholderStyle,
    this.textBgColor,
    this.bgColor,
    this.readOnly = false,
    this.contentHeight = 65,
    this.returnKeyDownKeyBoard = true
  });
  @override
  _InputStatefulWidgetState createState() => _InputStatefulWidgetState();
}

class _InputStatefulWidgetState extends State<MutipleRemarkWidget> {
  final double countHeight = 20;
  @override
  Widget build(BuildContext context) {
    return EnsureVisibleWhenFocused(
      focusNode: this.widget.focusNode,
      child: Column(
        children: <Widget>[
          Container(
            height: 45,
            padding: EdgeInsets.only(left: 16),
            child: Row(
              children: <Widget>[
                Text(widget.title,style: TextStyle(color: Color(0xff666666),fontSize: 14),),
                Spacer(),
              ],
            ),
          ),
          InputStatefulWidget(
            placeholder: this.widget.placeholder,
            maxLength: this.widget.maxLength,
              controller: this.widget.controller,
              showWaringText: this.widget.showWaringText,
              focusNode: this.widget.focusNode,
              textStyle: this.widget.textStyle,
              waringTextStyle: this.widget.waringTextStyle,
              placeholderStyle: this.widget.placeholderStyle,
              textBgColor: this.widget.textBgColor,
              bgColor: this.widget.bgColor,
              readOnly: this.widget.readOnly,
              contentHeight: this.widget.contentHeight,
              returnKeyDownKeyBoard: this.widget.returnKeyDownKeyBoard,
          ),

          Offstage(child:
          Container(
            height: 10,
            color: Color(0xffF7F8F9),
          ),
            offstage: widget.readOnly,
          )
        ],
      ),
    );
  }
}

